package com.systop.servicetool.comfig;

import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration  //配置文件
@EnableSwagger2  //启动swagger
public class SwaggerConfig {
    @Bean
    public Docket productApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                //扫描有注解的@ApiOperation注解的
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))

//扫描的包   //.apis(RequestHandlerSelectors.basePackage("com.systop.demoswagger.controller"))

                .paths(PathSelectors.any())
                .build();
    }

    //    配置文档信息
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("springboot整合Swagger")  //标题
                .description("Swagger文档")   //描述
// 联系人信息 Contact("联系人名字", "联系人访问链接(我写的博客地址)", "联系人邮箱");
                .contact(new Contact("璒璒","https://blog.csdn.net/kriswu_deng?type=blog","1486953997@qq.com"))
                .version("1.0")  //版本号
                .build();
    }

}
